<template>
	<view class="ctn">
		<view class="me_header">
			<view class="me_photo" :style="{ 'background-image': 'url(' + url + ')' }"> </view>
		</view>
		<view class="me_middle">
			<my-list
				v-for="(key, value) in ListData"
				:key="key"
				:propTitle="value"
				:boldValue="key == '无内容' ? false : true"
				:propValue="key"
			></my-list>
		</view>
	</view>
</template>

<script>
import service from '../../common/service/new_file.js';
import apiData from '../../common/utils/apiData.js';
export default {
	data() {
		return {
			url: '',
			ListData: {},
			userInform: null,
		};
	},
	methods: {
		getMyInform() {
			let _this = this;
			let data = apiData.getMyInform();
			service.common(data, {
				success: res => {
					this.userInform = res.data.VALUES[0];

					let userInform = this.userInform;
					console.log(userInform);
					let arry = userInform.photo;
					var str12 = arrayBufferToBase64(arry); //转换字符串
					// var outputImg = document.createElement('img');
					// outputImg.src = 'data:image/png;base64,'+str12;
					// // // append it to your page
					// document.body.appendChild(outputImg);
					function arrayBufferToBase64(buffer) {
						var binary = '';
						var bytes = new Uint8Array(buffer);
						var len = bytes.byteLength;
						for (var i = 0; i < len; i++) {
							binary += String.fromCharCode(bytes[i]);
						}
						return window.btoa(binary);
					}

					console.log(userInform);
					let newUerInfrom = {
						姓名: userInform.name,
						科室: userInform.pk_dept,
						手机: userInform.mobile,
						员工号: userInform.code,
						民族: userInform.nationality,
						出生日期: userInform.birthdate,
						参加工作时间: userInform.joinworkdate,
						政治面貌: userInform.polity,
						到院时间: userInform.jrsj,
						专业技术等级: userInform.pk_jobrank ? userInform.pk_jobrank : '无内容',
						管理岗位等级: userInform.jobglbdef4,
						技术职务: userInform.pk_techposttitle,
						职等: userInform.titlerank,
						职称类别: userInform.postseriesname,
						聘任时间: userInform.prsj,
					};
					this.ListData = newUerInfrom;
					this.url = 'data:image/png;base64,' + str12;
				},
			});
		},
	},
	onPullDownRefresh() {
		this.getMyInform();
	},
	onLoad() {
		this.getMyInform();
	},
};
</script>

<style lang="scss">
.ctn {
	padding: 0 36rpx;

	.me_header {
		margin: 48rpx 0;
		display: flex;
		justify-content: center;

		.me_photo {
			width: 316rpx;
			height: 460rpx;
			background-repeat: no-repeat;
			background-position: center;
			background-size: 100% 100%;
		}
	}
}
</style>
